package com.zkdcloud.repository;

import com.zkdcloud.domain.CartProduct;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.jfaster.mango.plugin.page.Page;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zk123
 * @version 2018/5/23
 */
@DB(table = "cart_product")
@Repository
public interface CartProductDao {
    String COLUMNS = "id,cart_id,product_id,name,quantity,unit_price,total_price,create_time";

    /**
     * 添加cartProduct
     *
     * @param cartProduct cp
     */
    @SQL("insert into #table ("+COLUMNS+") values(:id,:cartId,:productId,:name,:quantity,:unitPrice,:totalPrice,:createTime)")
    void add(CartProduct cartProduct);

    /**
     * 选出所有cartProduct by cartId
     *
     * @return cartProduct
     */
    @SQL("select * from #table where cart_id = :1")
    List<CartProduct> getAll(String cartId);
}
